<template>
  <div class="wrapper">
    <div class="search">
      <!-- <div class="search-title">请输入查询编号</div> -->
      <el-input
        class="search-input"
        v-model="input"
        placeholder="请输入查询编号内容"
        >请输入查询编号内容</el-input
      >
      <el-button class="search-btn" type="primary" plain @click="clickSubmit"
        >提交</el-button
      >
    </div>
    <div class="content" v-show="hasClicked">{{ zombie }}</div>
    <div>{{ $store.state.name }}</div>
  </div>
</template>

<script>
/* eslint-disable */
import '@/jquery-3.4.1.min.js';
export default {
  data() {
    return {
      input: '',
      hasClicked: '',
      zombie: ''
    };
  },
  methods: {
    clickSubmit(e) {
      alert('已提交，请等待返回');
      $.ajax({
        url: 'http://118.31.175.231:3000/search/' + this.input,
        type: 'get',
        success: function (data) {
          if (data.code == 0) {
            console.log(data);
            let ans = parseInt(data.ans);
            if (ans) {
              this.zombie = '该企业是僵尸企业,分类为' + data.type;
            } else {
              this.zombie = '该企业不是僵尸企业';
            }
            alert(this.zombie);
          } else {
            alert('未找到该企业相关信息');
          }
        },
        error: function (err) {
          console.log(err);
        }
      });
      this.hasClicked = true;
    }
  },
  mounted() {
    console.log(this.$store.state.name);
    // this.$nextTick(() => {
    //   this.$store.state.name = 'test';
    //   console.log(this.$store.state.name);
    // });
    setTimeout(() => {
      this.$store.state.name = 'test';
      console.log(this.$store.state.name);
    }, 2000);
  }
};
</script>

<style lang="stylus" scoped>
.wrapper {
  margin-top: 2rem;
}

.search {
  display: flex;
  height: 1rem;
  line-height: 1rem;
}

.search-input {
  // border 1px solid black;
}

.search-btn {
  margin-left: 1rem;
  height: 1rem;
}

.content {
  height: 4rem;
  width: 8rem;
  // background-color #f5f5f5;
  position: absolute;
  top: 7rem;
  left: 8rem;
  color: black;
}
</style>
